﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.factories;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.html;
using iTextSharp.text.xml;
using iTextSharp.tool.xml;
using System.IO;


namespace MalikSumLib.Utilities
{
   public class iTextMethods

    { 
        Document document = new Document(PageSize.A4);
        public string TextToWrite = "";
        public string FileName = "";

        public void ConvertText()
        {

            // 1- Create a Document.
            ;

            // 2- Get a PdfWriter instance.
            //PdfWriter writer = PdfWriter.GetInstance(document, new FileOutputStream(RESULT));
            PdfWriter.GetInstance(
                // that listens to the document
                document,
                // and directs a PDF-stream to a file
                new FileStream(FileName, FileMode.Create));
            // write sentance with different style  "samar"
            Font[] fonts = new Font[3];
            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
            BaseColor bc = BaseColor.RED;
            fonts[0] = new Font(bfTimes, 12, 6, BaseColor.RED);
            fonts[1] = new Font(bfTimes, 20, 10, BaseColor.ORANGE);
            fonts[2] = new Font(BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, false),12);


            // step 3: we open the document
            document.Open();

            for (int i = 0; i < 3; i++)
            {

                document.Add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
            }


            // step 4: we add a paragraph to the document
            document.Add(new Paragraph(TextToWrite));
            // 5- Close the Document.
            document.Close();


        }

    }
}
